package cn.com.pansky.action.order;

import java.io.UnsupportedEncodingException;

import net.vsame.url2sql.action.CommonAction;
import net.vsame.url2sql.helper.SqlHelper;
import net.vsame.url2sql.sql.Model;

import org.apache.commons.lang3.StringUtils;

import cn.com.pansky.service.OrderService;

/**
 * 订单管理
 * @author Administrator
 *
 */
public class OrderAction extends CommonAction{
	
	OrderService order = new OrderService();
	
	/**
	 * 历史订单查询
	 */
	public void orderList() {
		
		String userId = user.getString("AA001");
		order.hisOrder(userId);
	}
	
	/**
	 * 未支付订单查询
	 */
	public void unDealOrder() {
		
		String CA001 = getParam("CA001");
		String queryInfo = urlConfig.getVar("getCA006");
		Model model = SqlHelper.queryOne(queryInfo, CA001);
		if(model != null) {
			order.unDealOrder(model.getString("CA006"));  
		}else{
			datas.put("isPass", false);
			datas.put("info", "联系人不存在！");
			context.getDatas().put("result", datas);
		}
	}
	
	/**
	 * 取消订单
	 */
	public void cancleOrder() {
		String aaz288 = getParam("AAZ288");
		String bab502 = getParam("BAB502");
		if("YC".equals(bab502)) {
			aaz288 = aaz288.substring(0, aaz288.length()-7);
		}
		order.cancleOrder(aaz288);
	}
	
	/**
	 * 已支付订单查询
	 */
	public void dealOrder() {
		
//		order.dealOrder("");
	}
	
	public void check() throws UnsupportedEncodingException {
		OrderService os = new OrderService();
		String BAB502 = context.getSessionVal("BAB502").toString(); // 支付银行类别
		String AAE051 = context.getSessionVal("AAE051").toString(); // 支付银行类别
		String orderNumber = StringUtils.trimToEmpty(context.getParam("AAZ288"));
		os.orderQuery(BAB502, orderNumber, AAE051);
	}

	
}
